-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Console] Move out of quarantined #52270
[Console] Move out of quarantined #52270
Conversation
…vider test working. Still need to delete some files
Still working on sense editor's integration test Not running yet.
- remove ace ranges from sense editor spec and fix spec 🤦
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
💚 Build Succeeded |
src/legacy/core_plugins/console/public/np_ready/application/components/editor_example.tsx
Outdated
Show resolved
Hide resolved
...ugins/console/public/np_ready/application/containers/editor/legacy/console_editor/editor.tsx
Outdated
Show resolved
Hide resolved
...onsole/public/np_ready/application/containers/editor/legacy/console_editor/editor_output.tsx
Outdated
Show resolved
Hide resolved
...public/np_ready/application/containers/editor/legacy/console_editor/apply_editor_settings.ts
Outdated
Show resolved
Hide resolved
...le/public/np_ready/application/containers/editor/legacy/console_editor/keyboard_shortcuts.ts
Outdated
Show resolved
Hide resolved
...plugins/console/public/np_ready/application/containers/editor/legacy/console_menu_actions.ts
Outdated
Show resolved
Hide resolved
...e/public/np_ready/application/models/legacy_core_editor/__tests__/input_tokenization.test.js
Outdated
Show resolved
Hide resolved
...ore_plugins/console/public/np_ready/application/models/legacy_core_editor/create_readonly.ts
Outdated
Show resolved
Hide resolved
Clean up use of jquery Remove use of `done` inside async tests (input_tokenization.test.js) Capitalize elasticsearch Introduce helper for converting to AceRange inside legacy core editor Update typings Clean up imports Cleaner variable assignment
src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/curl.ts
Outdated
Show resolved
Hide resolved
import { CoreEditor, Token } from '../types'; | ||
import { TokenIterator } from './token_iterator'; | ||
|
||
export const MODE = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like a good candidate for conversion to an enum
, but not in this PR.
@@ -120,6 +136,11 @@ export interface CoreEditor { | |||
*/ | |||
clearSelection(): void; | |||
|
|||
/** | |||
* TODO: Document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this TODO supposed to be completed in this PR? The other new functions have documentation.
💔 Build Failed |
…dels/sense_editor/curl.ts Co-Authored-By: Rory Hunter <[email protected]>
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @jloleysens! I tested the scenarios listed in #42029, tried out the different settings, and used the history dropdown. Everything behaved as expected. Code LGTM, just had a few nitpicks and questions but nothing worth blocking on.
The architecture looks like a big improvement. I think we can continue to look for ways to make the the roles of and relationship between SenseEditor
and LegacyCoreEditor
more apparent. This could be as simple as a name change, or maybe we reconsider whether SenseEditor
should be a class and is better broken up into a number of pure functions (just speculating!). Just a casual thought based on some initial confusion I had about these two entities that was partially resolved by reading the source.
return false; | ||
} | ||
|
||
export function parseCURL(text: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I had no idea Console supported curl! This is really impressive but it seems like an undocumented feature which adds maintenance overhead, and I'm not sure it's particularly useful or if people even know about it. What do you think about planning for deprecating this feature in the future, e.g. 8.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check with the Training folks - I have a feeling it was mentioned when I took the ES Engineer 1 training recently.
"Copy as curl" I can see being more useful, but auto-parsing curl is unexpected. Well, to me, anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, tbh I didn't really know about this feature either 😅 happy to remove in future!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created #52570 to track my proposal.
src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/utils.ts
Outdated
Show resolved
Hide resolved
pos: any, | ||
prefix: any, | ||
callback: any | ||
DO_NOT_USE_SESSION: IEditSession, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the way you've named things that are deprecated!
src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/sense_editor.ts
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/sense_editor.ts
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/sense_editor.ts
Outdated
Show resolved
Hide resolved
lib/utils.js -> lib/utils.ts Rename engulfling range (sense_editor)
@elasticmachine merge upstream |
src/legacy/core_plugins/console/public/np_ready/lib/utils/utils.ts
Outdated
Show resolved
Hide resolved
.replace('^s*\n', '') | ||
.replace('\ns*^', ''); | ||
.replace('^\s*\n', '') // prettier-ignore | ||
.replace('\n\s*$', ''); // prettier-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Prettier is correct here - these patterns be surrounded in forward-slashes.
const jsonValue = JSON.parse(rawStringifiedValue)
.replace(/^\s*\n/, '')
.replace(/\n\s*$/, '');
I see what you mean about the difference with trim()
- it would remove all whitespace at the start or end of string, whereas these patterns are a little more subtle. Maybe it would be worth a comment, in case someone comes along later and replaces it with trim()
. 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Although I still query the usefulness of this vs. a simple trim()
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Come to think of it, this replace behaviour was part of legacy and was carried over from a previous alteration. I'm not convinced we want replace behaviour here at all. The value being altered was inside of """
which means string literal in Console. Newlines and whitespace should be preserved. I don't think those replace functions where actually doing anything when the behaviour was considered "correct":
"\n SELECT * FROM \"TABLE\"\n "
.replace('^\s*\n', '')
.replace('\n\s*$', '')
===
"\n SELECT * FROM \"TABLE\"\n "
// true
Automated and manual testing seem to confirm this. Would you mind taking a look too @pugnascotia ?
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* WiP, lotta broken things, working through new editor.ts * RowParser -> TS * Utils to TS and regular module * Finished first version of core & sense editor wrappers. Tokenizer provider test working. Still need to delete some files * WiP - moved A LOT of code around and busy fixing sense-editor tests * Fix sense editor test * Clean up mocks * Moved A LOT of code out of quarantined. Still working on sense editor's integration test Not running yet. * WiP still finishing up manual testing * Fix use of Ace Range and fix open documentation * Move out of quarantined! * Remove load remote editor state for now * - fix use of token iterator - remove ace ranges from sense editor spec and fix spec 🤦 * Address getSelectionRange document TODO Clean up use of jquery Remove use of `done` inside async tests (input_tokenization.test.js) Capitalize elasticsearch Introduce helper for converting to AceRange inside legacy core editor Update typings Clean up imports Cleaner variable assignment * Update src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/curl.ts Co-Authored-By: Rory Hunter <[email protected]> * Remove commented-out code lib/utils.js -> lib/utils.ts Rename engulfling range (sense_editor) * Rename format request function * utils.ts default export usage cleanup * Update replace regex and add another utils test * Remove legacy replace behaviour * Fix typo in comment
* WiP, lotta broken things, working through new editor.ts * RowParser -> TS * Utils to TS and regular module * Finished first version of core & sense editor wrappers. Tokenizer provider test working. Still need to delete some files * WiP - moved A LOT of code around and busy fixing sense-editor tests * Fix sense editor test * Clean up mocks * Moved A LOT of code out of quarantined. Still working on sense editor's integration test Not running yet. * WiP still finishing up manual testing * Fix use of Ace Range and fix open documentation * Move out of quarantined! * Remove load remote editor state for now * - fix use of token iterator - remove ace ranges from sense editor spec and fix spec 🤦 * Address getSelectionRange document TODO Clean up use of jquery Remove use of `done` inside async tests (input_tokenization.test.js) Capitalize elasticsearch Introduce helper for converting to AceRange inside legacy core editor Update typings Clean up imports Cleaner variable assignment * Update src/legacy/core_plugins/console/public/np_ready/application/models/sense_editor/curl.ts Co-Authored-By: Rory Hunter <[email protected]> * Remove commented-out code lib/utils.js -> lib/utils.ts Rename engulfling range (sense_editor) * Rename format request function * utils.ts default export usage cleanup * Update replace regex and add another utils test * Remove legacy replace behaviour * Fix typo in comment
Summary
This is a continuation (and completion) of a refactor to the public code in Console started with #43346.
Primary objectives
public/quarantined
. This entails reviewing and ensuring that we minimise/demarcate direct usage ofbrace
. We are not planning on switching to Monaco in the immediate future, but this contribution should help a lot with any such future effort.CoreEditor
interface and implement the newSenseEditor
model which uses it.Overview of
public/np_ready
directory structure (and architecture):application
should contain all application relevant logicmodels
: contain business logic for our special console language (legacy_core_editor
) and knowledge of requests (sense_editor
).1.
legacy_core_editor
should contain all wiring up ofbrace
containers
: all UI components that interact withcontext
components
: all pure/function UI componentscontexts
: contain the mechanism for how we share our flux-like stores ([Console] Refactoring more legacy code and implementing minor fixes #51312)stores
: contain the logic for how state can change and the shape of state sliceshooks
: contain all actions that can affect state changes and don't directly speak to rendering UIlib
types
should live here (e.g.,ace_token_provider
) surfaces an implementation ofTokenProvider
without leaking Ace interfaces.types
- folder can be renamed, but named istypes
to follow conventions in ES UI management apps. This houses only types + interfaces, no real values.How to review
CoreEditor
andSenseEditor
interfaces. They contain new logic and will benefit from having their interfaces reviewed!row
->lineNumber
for our position interfaces there is risk of "off-by-one" regressions. These will probably be very hard to spot, but manual and automated testing has caught a large number of these - but still keep an eye out for them!Other goodies
Some fixes were made as part of this PR:
RowParser.ts
'sgetRowParseMode
which had an off-by-one regression (example of fix:if (lineNumber < linesCount + 1)...
)sense_editor.test.js
had an issue where tests where not correctly reporting failure 🤦♂onDoubleClick
inside ofconsole_history
container